Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(usage-report): avoid report failure when previous stats are invalid #8240

Merged
merged 2 commits into from
Jan 20, 2025

Conversation

b-Nollet
Copy link
Contributor

Description

The usage report plugin ended up failing to send reports over and over if the stored stats file was an empty file (or an incorrect json) at some point.
This change makes the plugin consider that previous stats don't exist if the json file cannot be parsed, which makes it able to send the report (without the "evolution" part) and rewrite the stats file.

https://help.vates.tech/#ticket/zoom/33177

Checklist

  • Commit
    • Title follows commit conventions
    • Reference the relevant issue (Fixes #007, See xoa-support#42, See https://...)
    • If bug fix, add Introduced by
  • Changelog
    • If visible by XOA users, add changelog entry
    • Update "Packages to release" in CHANGELOG.unreleased.md
  • PR
    • If UI changes, add screenshots
    • If not finished or not tested, open as Draft

Review process

This 2-passes review process aims to:

  • develop skills of junior reviewers
  • limit the workload for senior reviewers
  • limit the number of unnecessary changes by the author
  1. The author creates a PR.
  2. Review process:
    1. The author assigns the junior reviewer.
    2. The junior reviewer conducts their review:
      • Resolves their comments if they are addressed.
      • Adds comments if necessary or approves the PR.
    3. The junior reviewer assigns the senior reviewer.
    4. The senior reviewer conducts their review:
      • If there are no unresolved comments on the PR → merge.
      • Otherwise, we continue with 3.
  3. The author responds to comments and/or makes corrections, and we go back to 2.

Notes:

  1. The author can request a review at any time, even if the PR is still a Draft.
  2. In theory, there should not be more than one reviewer at a time.
  3. The author should not make any changes:
    • When a reviewer is assigned.
    • Between the junior and senior reviews.

@b-Nollet b-Nollet force-pushed the usage-report-empty-json branch from 8a330ce to bbb75fa Compare January 10, 2025 15:38
@pdonias
Copy link
Member

pdonias commented Jan 13, 2025

Just to make sure I understand what was happening: the plugin was still working in normal cases because:

  • either the old stats file wouldn't exist, thus pReadFile would throw an ENOENT, which is properly caught and ignored
  • or the file would exist with a proper JSON inside

So, the edge case you're fixing wasn't introduced by a specific change, it has always been there, right?

@b-Nollet
Copy link
Contributor Author

b-Nollet commented Jan 13, 2025

Just to make sure I understand what was happening: the plugin was still working in normal cases because:

* either the old stats file wouldn't exist, thus `pReadFile` would throw an `ENOENT`, which is properly caught and ignored

* or the file would exist with a proper JSON inside

So, the edge case you're fixing wasn't introduced by a specific change, it has always been there, right?

Yes it behaves as you described.

I'm making this change because a customer (ticket link in PR description) had no usage reports for several months because his stats file was empty, making each report fail and leave the stats file unchanged.
I don't know what caused the stats file to get like this, but I think it's probably better to have this safety measure.

@b-Nollet b-Nollet force-pushed the usage-report-empty-json branch from bbb75fa to a1b430e Compare January 16, 2025 15:48
@b-Nollet b-Nollet force-pushed the usage-report-empty-json branch from a1b430e to 09b0eff Compare January 20, 2025 10:07
@b-Nollet b-Nollet requested a review from fbeauchamp January 20, 2025 10:13
@fbeauchamp fbeauchamp merged commit 4744071 into master Jan 20, 2025
1 check failed
@fbeauchamp fbeauchamp deleted the usage-report-empty-json branch January 20, 2025 10:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants